import request from '@/utils/request'

export function add(data) {
  return request({
    url: '/product/attrgroup',
    method: 'post',
    data
  })
}

export function del(id) {
  return request({
    url: '/product/attrgroup/' + id,
    method: 'delete'
  })
}

export function delRelevance(attrId, groupId) {
  return request({
    url: '/product/attrgroup/' + attrId + '/' + groupId,
    method: 'delete'
  })
}

export function edit(data) {
  return request({
    url: '/product/attrgroup',
    method: 'put',
    data
  })
}

export function getAttrGroup(id) {
  return request({
    url: '/product/attrgroup/' + id,
    method: 'get'
  })
}

export function listAttrGroup(params) {
  return request({
    url: '/product/attrgroup/list/' + params.catelogId + '/' + params.pageNum + '/' + params.pageSize,
    method: 'get',
    params
  })
}

export function listAttrGroupAll(params) {
  return request({
    url: '/product/attrgroup/list/' + params.catelogId,
    method: 'get'
  })
}

export function listAttrGroupAllBygroupId(groupId) {
  return request({
    url: '/product/attrgroup/group/list/' + groupId,
    method: 'get'
  })
}

export function listAttrGroupAllNoRelevance(params) {
  return request({
    url: '/product/attrgroup/noattr/relevance/list/' + params.groupId + '/' + params.pageNum + '/' + params.pageSize,
    method: 'get'
  })
}

export function findAttrAndGroupByCatelogId(params) {
  return request({
    url: '/product/attrgroup/group/list/withattr/' + params.catelogId,
    method: 'get'
  })
}

export function addRelation(data) {
  return request({
    url: '/product/attrattrgrouprelation',
    method: 'post',
    data
  })
}

export default { add, edit, del, delRelevance, getAttrGroup, listAttrGroup, listAttrGroupAllBygroupId, listAttrGroupAllNoRelevance, addRelation, findAttrAndGroupByCatelogId }
